//
//  UtilsMacro.h
//  XiaoMiao
//
//  Created by 23 on 2017/11/4.
//  Copyright © 2017年 smallyou. All rights reserved.
//

#ifndef UtilsMacro_h
#define UtilsMacro_h

//////////////////////////////////日志输出//////////////////////////////////
#ifdef DEBUG
#define XMLog(...) NSLog(__VA_ARGS__)
#define debugMethod() NSLog(@"%s", __func__)
#else
#define XMLog(...)
#define debugMethod()
#endif



//////////////////////////////////颜色工具//////////////////////////////////
/*十六进制颜色*/
#define HEXColor(hex) [UIColor colorWithRed:((float)((hex & 0xFF0000) >> 16))/255.0 \
green:((float)((hex & 0xFF00) >> 8))/255.0 \
blue:((float)(hex & 0xFF))/255.0 \
alpha:1.0]

/*十六进制+alpha通道颜色*/
#define HEXPColor(hex, a) [UIColor colorWithRed:((float)((hex & 0xFF0000) >> 16))/255.0 \
green:((float)((hex & 0xFF00) >> 8))/255.0 \
blue:((float)(hex & 0xFF))/255.0 \
alpha:a]

/*RGB颜色（及alpha通道颜色）*/
#define kRGBColor(r, g, b)                  [UIColor colorWithRed:r/255.f green:g/255.f blue:b/255.f alpha:1.f]
#define kRGBAColor(r, g, b, a)              [UIColor colorWithRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:a]

/*从十六进制字符串获取颜色*/
#define colorFromHex( _hexValue_ ) ( [UIColor colorWithHexString:_hexValue_] )
/*十六进制颜色（数值）*/
#define kAppCustomColor(c) HEXColor(c)



//////////////////////////////////APP颜色//////////////////////////////////
/*主题颜色*/
#define kMainBlueColor                        kRGBColor(0, 176, 255) // 主题蓝色
#define kBgColor                           HEXColor(0xF7F7F7)     // 背景颜色
#define kTextBlackColor                           HEXColor(0x383838)     // 黑色文字
#define kTextGrayColor                           HEXColor(0xc4c4c4)     // 灰色文字

#define KItemSelectedColor     HEXColor(0xefefef)                      // 选择背景蓝色

#define KItemNormalColor                           HEXColor(0xf7faff)     // 未选择背景灰色

#define kWhiteColor [UIColor whiteColor]
#define kBlackColor [UIColor blackColor]
#define kDarkGrayColor [UIColor darkGrayColor]
#define kLightGrayColor [UIColor lightGrayColor]
#define kGrayColor [UIColor grayColor]
#define kRedColor [UIColor redColor]
#define kGreenColor [UIColor greenColor]
#define kBlueColor [UIColor blueColor]
#define kCyanColor [UIColor cyanColor]
#define kYellowColor [UIColor yellowColor]
#define kMagentaColor [UIColor magentaColor]
#define kOrangeColor [UIColor orangeColor]
#define kPurpleColor [UIColor purpleColor]
#define kBrownColor [UIColor brownColor]
#define kClearColor [UIColor clearColor]

#define HEX_RGB(V)        [UIColor colorWithRGBHex:V]

#define kImage(imageName) [UIImage imageNamed:imageName]

//////////////////////////////////APP字体//////////////////////////////////


#pragma mark ----------------Font-----------------
/***  普通字体 */
#define kFont(size) [UIFont systemFontOfSize:size]
/***  粗体 */
#define kBoldFont(size) [UIFont boldSystemFontOfSize:size]





//////////////////////////////////尺寸相关//////////////////////////////////
#define kScreenWidth                   [[UIScreen mainScreen] bounds].size.width
#define kScreenHeight                  [[UIScreen mainScreen] bounds].size.height
#define kWeakSelfWidth                 self.view.frame.size.width
#define kWeakSelfHeight                self.view.frame.size.height
#define ORIGINAL_MAX_WIDTH             960.0f

#define kRect(x, y, w, h)              CGRectMake(x, y, w, h)
#define kSize(w, h)                    CGSizeMake(w, h)
#define kPoint(x, y)                   CGPointMake(x, y)

//比例宏
#define KRealValue(value) ((value)/375.0f*[UIScreen mainScreen].bounds.size.width)

//////////////////////////////////强弱引用//////////////////////////////////
#define WEAKSELF typeof(self) __weak weakSelf = self;
#define STRONGSELF typeof(weakSelf) __strong strongSelf = weakSelf;





//////////////////////////////////系统机型//////////////////////////////////
#define iOS6                                (IOSVersion >= 6.0 && IOSVersion < 7.0)
#define iOS7                                (IOSVersion >= 7.0 && IOSVersion < 8.0)
#define iOS8                                (IOSVersion >= 8.0)
#define iOS6Later                           (!(IOSVersion < 6.0f))
#define iOS7Later                           (!(IOSVersion < 7.0f))
#define iOS8Later                           (!(IOSVersion < 8.0f))
#define IOSVersion                          [[[UIDevice currentDevice] systemVersion] floatValue]

#define iOS11_AND_LATER [[UIDevice currentDevice].systemVersion floatValue] >= 11.0
#define iOS10_AND_LATER [[UIDevice currentDevice].systemVersion floatValue] >= 10.0
#define iOS9_AND_LATER [[UIDevice currentDevice].systemVersion floatValue] >= 9.0
#define iOS8_AND_LATER [[UIDevice currentDevice].systemVersion floatValue] >= 8.0

#define Iphone4Screen                       ([UIScreen mainScreen].bounds.size.height == 480.0f)
#define Iphone5Screen                       ([UIScreen mainScreen].bounds.size.height == 568.0f)
#define Iphone6Screen                       ([UIScreen mainScreen].bounds.size.height == 667.0f)
#define Iphone6PScreen                      ([UIScreen mainScreen].bounds.size.height == 736.0f)
#define Ipad                                [[UIDevice currentDevice].model isEqualToString:@"iPad"]

#define iPhone4     ([UIScreen mainScreen].bounds.size.height == 480)
#define iPhone5     ([UIScreen mainScreen].bounds.size.height == 568)
#define iPhone45     ([UIScreen mainScreen].bounds.size.height <= 568)
#define iPhone6     ([UIScreen mainScreen].bounds.size.height == 667)
#define iPhone6p     ([UIScreen mainScreen].bounds.size.height == 736)
#define iPhoneX     ([UIScreen mainScreen].bounds.size.height == 812)

//////////////////////////////////工具相关//////////////////////////////////
/*偏好设置*/
#define XMUerDefault [NSUserDefaults standardUserDefaults]
/*沙盒路径*/
#define kDocumentPath NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES).firstObject




//////////////////////////////////数据处理//////////////////////////////////
#define NullStrable(value)                       (value != nil ? value : @"")
#define StringNotNull(x)                         (![x isKindOfClass:[NSNull class]] && x != nil && ![x isEqual:@"<null>"])
#define StringNotZero(x)                         [ValueNotNSNull(x) floatValue]>0.f?[ValueNotNSNull(x) stringValue]:nil
#define ValueNotNSNull(value)                    ((value && ![value isEqual:[NSNull null]])? value : nil)
#define ValueIsKindNull(value)                    ((value && ![value isKindOfClass:[NSNull class]]))
#define StringNotEmpty(str)                      (str && (str.length > 0))
#define ArrayNotEmpty(arr)                       (arr && (arr.count > 0))
#define StringNew(obj)                           [NSString stringWithFormat:@"%@",obj]
#define StringNewLD(obj)                           [NSString stringWithFormat:@"%ld",obj]
#define StringNewData(obj)                           [NSString stringWithFormat:@"%lddata",obj]

#define Dictionary(obj)                          (obj && [obj isKindOfClass:[NSDictionary class]])
#define Array(obj)                               (obj && [obj isKindOfClass:[NSArray class]])


//////////////////////////////////other//////////////////////////////////
#define kLoadingMsg                     @"加载中.."
#define kDefaultPlaceholdeImage       [UIImage imageNamed:@"ic_common_avatar_default"]       // 默认占位图片名
#define kAgeArray                      @[@"00后", @"90后", @"80后", @"70后", @"60后", @"50后"]
#define kSexArray                      @[@"保密", @"男", @"女"]


#define DataBasePath [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)[0] stringByAppendingPathComponent:@"Data.sqlite"]


#endif /* UtilsMacro_h */


















